package net.hzlj.platform.enterprise.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import net.hzlj.platform.enterprise.common.Constant;
import net.hzlj.platform.enterprise.service.InitService;
import net.hzlj.platform.enterprise.service.MainService;
import net.hzlj.platform.enterprise.utils.ServiceUtils;

/**
 * @Description 系统服务
 * @Author: Jason.Zhang zhangyujn1989ok@gmail.com
 * @Date: 2016-11-30 10:36:36
 */
public class LauncherReceiver extends BroadcastReceiver {

    private static final String TAG = LauncherReceiver.class.getSimpleName();

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        Log.i(TAG, "onReceive action :" + action);
        if (!ServiceUtils.isServiceRunning(context,
                "net.hzlj.platform.enterprise.service.MainService")) {
            context.startService(new Intent(context, MainService.class));
        }
        if (Constant.Intent.ACTION_UPDATE_USER_INFO.equals(action)){
            Intent i = new Intent(context, InitService.class);
            i.setAction(action);
            context.startService(i);
        }
    }
}
